<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>检测文件管理系统</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/bootstrap.min.css">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/font-awesome.min.css">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="${request.contextPath}/statics/css/all-skins.min.css">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/main.css">
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<style type="text/css">
	html,body{ height: 100%!important;}
	.bodys{background: url(${request.contextPath}/statics/images/backs.png) no-repeat center center; background-size: 100% auto;}
	.login-box{ width: 25%; position: absolute; top: 50%; right: 4%; margin: 0; transform: translateY(-50%);}
	.login-box-body{ background: none;}
	.login-box-msg{ padding: 0 ; padding-bottom: 30px;text-align: left; color: #3A66A4; font-size: 22px; font-weight: bold;}
	.form-group{margin: 0!important; margin-bottom: 20px!important;}
	.los input{ height: 45px!important; padding-right: 5px!important; padding-left: 40px!important; background: #fff!important;}
	.los1 input{ border-color:#0079c3 ; box-shadow: 0 0 10px #0079c3!important;}
	.row{ border-top: none!important;}
	.bots{ width: 100%; height: 50px; background: #275BD1; line-height: 50px; text-align: center; color: #fff; font-size: 24px; font-weight: bold; border: none;}
	.spans img{ width: 16px; height: 16px;}
	.spans{ width: 16px; height: 16px; left: 10px; top: 5px;}
	.jizhu {
	    width: auto;
	    height: 20px;
	    color: #A2A2A2;
	    font-size: 14px;
	}
</style>
<body class="hold-transition login-page bodys">
<div class="login-box" id="rrapp" v-cloak>
  <!--<div class="login-logo">
    <b>检测文件管理系统</b>
  </div>-->
  <!-- /.login-logo -->
  <div class="login-box-body">
      <!--<p class="login-box-msg">管理员登录</p>-->
      <div v-if="error" class="alert alert-danger alert-dismissible">
        <h4 style="margin-bottom: 0px;"><i class="fa fa-exclamation-triangle"></i> {{errorMsg}}</h4>
      </div>
      <div class="form-group has-feedback los los1" >
        <input type="text" class="form-control" placeholder="激活码" v-model="activCode" id="activCode" onfocus="focus1(this)" >
        <span class="form-control-feedback spans">
        	<img src="${request.contextPath}/statics/images/possword.png"/>
        </span>
      </div>
      <div class="form-group has-feedback los " >
        <input type="text" class="form-control" v-model="username" placeholder="账号" id="username" onfocus="focus1(this)">
        <span class="form-control-feedback spans">
        	<img src="${request.contextPath}/statics/images/username.png"/>
        </span>
      </div>
      <div class="form-group has-feedback los">
        <input type="password" class="form-control" v-model="password" placeholder="密码" id="password" onfocus="focus1(this)">
        <span class="form-control-feedback spans">
       		<img src="${request.contextPath}/statics/images/possword1.png"/>
        </span>
      </div>
<!--      <div class="form-group has-feedback">-->
<!--        <input type="text" class="form-control" v-model="captcha" @keyup.enter="login" placeholder="验证码">-->
<!--        <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>-->
<!--      </div>-->
<!--      <div class="form-group has-feedback">-->
<!--        <img alt="如果看不清楚，请单击图片刷新！" class="pointer" :src="src" @click="refreshCode">-->
<!--        &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" @click="refreshCode">点击刷新</a>-->
<!--      </div>-->
      
      <div class="jizhu">
       	<input type="checkbox" id="savePassword"  onclick="SavePassword()">记住密码
		  </div>
      <div class="row">
        
        <!-- /.col -->
        <div style="width: 100%;">
          <button type="button" class="bots" @click="login">登 录</button>
        </div>
        <!-- /.col -->
      </div>
    <!-- /.social-auth-links -->

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<script src="${request.contextPath}/statics/libs/jquery.min.js"></script>
<script type="text/javascript">
	function focus1(obj){
		$(obj).parent().addClass('los1').siblings().removeClass('los1')
	}

    function SavePassword()
    {
        if(document.getElementById("savePassword").checked)
        {debugger
            var usernames = $('#username').val()
            var passwords = $('#password').val()
            var activCodes = $('#activCode').val()
            setCookie('username',usernames,7);
            setCookie('password',passwords,7);
            setCookie('activCode',activCodes,7);
        }
        else
        {
            localStorage.rmbPassword = false;
        }
    }

    $(function(){
        if(getCookie('username') && getCookie('password') && getCookie('activCode')){
            $('#username').val(getCookie('username'))
            $('#password').val(getCookie('password'))
            $('#activCode').val(getCookie('activCode'))
            vm.username = getCookie('username')
            vm.password = getCookie('password')
            vm.activCode = getCookie('activCode')
            document.getElementById("savePassword").checked = true;
        }
    })

    function getCookie(name){
        var reg = RegExp(name+'=([^;]+)');
        var arr = document.cookie.match(reg);
        if(arr){
            return arr[1];
        }else{
            return '';
        }
    };

    function setCookie(name,value,day){
        var date = new Date();
        date.setDate(date.getDate() + day);
        document.cookie = name + '=' + value + ';expires='+ date;
    };
</script>
<script src="${request.contextPath}/statics/libs/vue.min.js"></script>
<script src="${request.contextPath}/statics/libs/bootstrap.min.js"></script>
<script src="${request.contextPath}/statics/libs/jquery.slimscroll.min.js"></script>
<script src="${request.contextPath}/statics/libs/fastclick.min.js"></script>
<script src="${request.contextPath}/statics/libs/app.js"></script>
<script type="text/javascript">
	
var vm = new Vue({
	el:'#rrapp',
	data:{
		username: '',
		password: '',
		captcha: '',
		error: false,
		errorMsg: '',
		src: 'captcha.jpg',
        activCode:''
	},
	beforeCreate: function(){
		if(self != top){
			top.location.href = self.location.href;
		}
	},
	methods: {
		refreshCode: function(){
			this.src = "captcha.jpg?t=" + $.now();
		},
		login: function (event) {
			var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha+"&activCode="+vm.activCode;
			$.ajax({
				type: "POST",
			    url: "sys/login",
			    data: data,
			    dataType: "json",
			    success: function(result){
					if(result.code == 0){//登录成功
						parent.location.href ='index.html';
					}else{
						vm.error = true;
						vm.errorMsg = result.msg;
						
						vm.refreshCode();
					}
				}
			});
		}
	}
});

	
</script>
</body>
</html>
